package cn.bdqn.dao;

import cn.bdqn.pojo.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 *  使用注解进行增删改查
 */
public interface UserMapper {
    @Select("SELECT * FROM `user`")
    List<User> getUserList();

    @Select("SELECT * FROM `user` WHERE  `id` = #{id}")
    User getUserById(@Param("id") int id);

    @Select("SELECT * FROM `user` WHERE `name` LIKE #{name}")
    List<User> getUserByLike(@Param("name") String name);

    @Insert("INSERT INTO `user`(`id`,`name`,`pwd`) VALUE(#{id},#{name},#{pwd})")
    int addUser(User user);

    @Update("UPDATE `user` SET `name`= #{name} ,`pwd`= #{pwd} WHERE `id` = #{id} ")
    int updateUser(User user);

    @Delete("DELETE FROM `user` WHERE `id` = #{id}")
    int deleteUser(@Param("id") int id);
}
